﻿using System.Xml;
using Windows.Foundation;

namespace LinkPad.Shapes
{
    public interface IManagedShape
    {
        #region Properties

        /// <summary>
        ///  returns the bounding box of the shape in the view
        /// </summary>
        Rect BoundingBox { get; }

        /// <summary>
        ///  returns the absolute bounding box of the shape in the real world
        /// </summary>
        Rect RealBoundingBox { get; }

        /// <summary>
        ///  returns true if the real bounding box is ready
        /// </summary>
        bool RealBoundingBoxReady { get; }

        ShapeManager ShapeManager { get; }

        #endregion

        #region Methods

        /// <summary>
        ///  Adds all shapes contained by this managed shape to the end of the shape list of the canvas so after that it shows at the top
        /// </summary>
        void AddToCanvas();

        /// <summary>
        ///  Removes all shapes contained by this managed shape from the canvas
        /// </summary>
        void RemoveFromCanvas();

        /// <summary>
        ///  Returns all indices to the shapes contained by the managed shape added to the shape list of the canvas
        /// </summary>
        /// <returns>All indices sorted ascendingly</returns>
        int[] IndicesInCanvas();

        /// <summary>
        ///  Inserts the shapes contained by the managed shape to the specified location in the shape list of the canvas
        /// </summary>
        /// <param name="index">The specified location (which should be the lowest of all items if multiple</param>
        void InsertToCanvas(int index);

        /// <summary>
        ///  returns the distance between the shape and the specified point
        /// </summary>
        /// <param name="point">The point between which and the shape the distance is to be calculated</param>
        /// <returns>The distance or 0 or any negative value if the point is on the boundaries of or inside the shape</returns>
        double DistanceToPoint(Point point);

        /// <summary>
        ///  Changes the shape location and size according to transformer set by the shape manager
        /// </summary>
        void Transform();

        /// <summary>
        ///  Saves the shape to the specified XML writer
        /// </summary>
        /// <param name="xmlWriter">XML writer to write the stream to</param>
        void WriteToXml(XmlWriter xmlWriter);

        /// <summary>
        ///  Loads the shape from the specified XML reader
        /// </summary>
        /// <param name="xmlReader">XML reader to read the stream from</param>
        /// <returns>true if reading is successful</returns>
        bool ReadFromXml(XmlReader xmlReader);

        #endregion
    }
}
